package ipdesk.model.analysis.action;

import ipdesk.model.analysis.bean.AnalysisBrandBean;
import ipdesk.model.analysis.bean.AnalysisDesignBean;
import ipdesk.model.analysis.dao.AnalysisBrandDao;
import ipdesk.model.analysis.dao.AnalysisDesignDao;

import java.util.List;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.opensymphony.xwork2.Preparable;

import ecg.util.Time;

public class AnalysisDesignAction extends ActionSupport implements Preparable, ModelDriven<AnalysisDesignBean>
{
	private AnalysisDesignBean analysisDesignBean;
	private List<AnalysisDesignBean> analysisDesignList;
	
	
	public String execute() throws Exception
	{
		String startDt	= "";
		String endDt	= "";
		
		if(analysisDesignBean.getStartDt() == null || "".equals(analysisDesignBean.getStartDt())){
			startDt	= Time.getYearMonthDayWithDash();
			// 값이 없는경우에는 시작일자는 01일을 시작값으로 한다.
			startDt = startDt.substring(0, 5);
			
			String startDay = "01-01";
			startDt = startDt.concat(startDay);
			
			analysisDesignBean.setStartDt(startDt);
		}
		
		if(analysisDesignBean.getEndDt() == null || "".equals(analysisDesignBean.getEndDt())){
			endDt	= Time.getYearMonthDayWithDash();
			analysisDesignBean.setEndDt(endDt);
		}
		
		
		
		analysisDesignList = AnalysisDesignDao.getInstance().getAnalysisDesignList(analysisDesignBean);
		
		
		return SUCCESS;
	}

	public void prepare() throws Exception {
		analysisDesignBean = new AnalysisDesignBean();
		
	}

	public AnalysisDesignBean getModel() {

		return analysisDesignBean;
	}



	public List<AnalysisDesignBean> getAnalysisDesignList() {
		return analysisDesignList;
	}
}

